package com.itheima.springbootcondition.config;

import com.itheima.springbootcondition.condition.ClassCondition;
import com.itheima.springbootcondition.condition.ConditionOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import com.itheima.springbootcondition.pojo.User;

@Configuration//这是一个配置类
public class UserConfig {

    @Bean
//    @Conditional(ClassCondition.class)
//    @ConditionOnClass("redis.clients.jedis.Jedis")
    @ConditionalOnProperty(name = "itcast",havingValue = "itheima")
    public User user() {
        return new User();
    }

    @Bean
    @ConditionalOnMissingBean(User.class)
    public User user2() {
        return new User();
    }
}
